<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        .nav {
            margin: 100px;
            position: relative;
        }
        ul {
            overflow: hidden;
            position: relative;
            z-index: 1;
            
        }
        li {
            float: left;
            width: 83px;
            height: 42px;
            list-style: none;  
            text-align: center; 
            line-height: 42px;
        }
        img{
            position: absolute;
            left: 0;
            top: 0;
        }
    </style>
</head>
<body>
    <div class="nav">
        <ul>
            <li>你好啊</li>
            <li>你好啊</li>
            <li>你好啊</li>
            <li>你好啊</li>
            <li>你好啊</li>
            <li>你好啊</li>
            <li>你好啊</li>
        </ul>
        <img src="cloud.gif" alt="">
    </div>
    <script src='../common.js'></script>
    <script>
        //获取元素
        var liList = document.querySelectorAll('.nav li');
        var img = document.querySelector('img');
        //注册事件
        var init = liList[0].offsetLeft;
        for(i = 0; i < liList.length; i++) {
            liList[i].onmouseenter = liMouseenter
            liList[i].onmouseleave = liMouseLeave
            liList[i].onclick = liClick
        }
        function liMouseenter() {
            animationAll(img,{left:this.offsetLeft})
        }
        function liMouseLeave() {
            animationAll(img,{left:init})
        }
        function liClick() {
            init = this.offsetLeft;
        }


    </script>
    <script src='../jquery-1.12.4.js'></script>
    <script>
        // $(function(){
        //     var init = $('img').position().left;
        //     $('.nav li').on('mouseenter',function(){
        //         $('img').stop(true,false).animate({left:$(this).position().left})
        //     }).on('mouseleave',function(){
        //         $('img').stop(true,false).animate({left:init})
        //     }).on('click',function(){
        //         init = $(this).position().left;
        //     })
        // })
    </script>
</body>
</html>